package cn.tedu.csmall.order;

import cn.tedu.csmall.order.config.DefaultFeignConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @EnableFeignClients(defaultConfiguration = DefaultFeignConfig.class)
 * 全局生效
 */

// Generated by https://start.springboot.io
// 优质的 spring/boot/data/security/cloud 框架中文文档尽在 => https://springdoc.cn
@SpringBootApplication
@EnableFeignClients(defaultConfiguration = DefaultFeignConfig.class)
public class CsmallOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(CsmallOrderApplication.class, args);
    }

    //初始化RestTemplate 交给spring容器管理
    @Bean
    @LoadBalanced //开启负载均衡，根据服务名称去注册中心找到实际的服务信息，最终在转换为请求地址
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

}
